home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-28 | 12.1 KB | 320 lines | [TEXT/KAHL] |
- **************************************
- **************************************
-
- FOR THINK v6 AND EARLIER USERS
-
- **************************************
- **************************************
-
- This file provides instructions on how to build the required support
- libraries if you are not using THINK version 7.0 or later.
-
- This file also includes some general guidance for users of other compilers,
- but because I only own THINK C I can only provide general guidance.
- CodeWarrior libraries and example project files are provided courtesy of
- Dirk Froehling, so the only Macintosh compiler for which this remains an
- issue is MPW.
-
- Use of Mac F2C code with the C++ compiler is strongly not recommended with
- version 6 of the THINK/Symantec C++ compiler. There is no C++ compiler
- prior to version 6. For these reasons, the C++ libraries and C++ model
- projects are omitted from the below discussions.
-
- If you have THINK version 6, you can upgrade to version 7 (minus Visual
- Architect and TCL version 2.0) for free. Look in your favorite Macintosh
- archive site for the free updater.
-
-
-
- CONTENTS
- ********
-
- A. BUILDING THE SUPPORT LIBRARIES USING THINK C
-
- B. CONVERTING THE TEST PROJECT
-
- C. HOW TO USE THE MODEL PROJECT
-
- D. IF YOU USE COMPILERS OTHER THAN THINK C
-
-
-
- A. BUILDING THE SUPPORT LIBRARIES USING THINK C
- *************************************************
-
- There are five support libraries required to run programs translated by
- Mac F2C. These libraries are:
-
- (1) ANSI F2C
- (2) unix F2C
- (3) libI77a
- (4) libI77b
- (5) libF77
-
- You should first install these as specified in the "INSTRUCTIONS (THINK)"
- file. The first two libraries belong in the "Standard Libraries" folder;
- the second three belong in the "Mac F2C Libraries" folder which you should
- place in the folder that contains the THINK Project Manager (or the THINK C
- application for versions prior to version 6).
-
-
- TO MAKE "ANSI F2C" AND "unix F2C"
-
- Delete "ANSI F2C" and "unix F2C" provided with Mac F2C. Duplicate the
- "ANSI" and "unix" libraries in the "Standard Libraries" folder (the ones
- provided by Symantec). Rename the duplicates "ANSI F2C" and "unix F2C".
- Open each one and do the following:
-
- (a) Remove objects
-
- (b) In the "Options" dialog select:
- - 4-byte integers
- - 8-byte doubles
- - 68020 code generation (strongly recommended, not required)
-
- (c) In the "Set Project Type" dialog select:
- - Far code
- - Far data
-
- (d) Bring Up To Date
-
-
- TO MAKE "libI77a", "libI77b", AND "libF77"
-
- In the "Mac F2C Libraries" folder you will find these three libraries and
- two folders of source code ("libI77 Sources" and "libF77 Sources"). In the
- folder "For THINK v6 and Earlier Users" you will find corresponding text
- files called "Contents of xxx". The files "Contents of xxx" contain
- detailed descriptions of the what each library contains.
-
- The process is the same for all three libraries. I will illustrate it
- with "libI77a":
-
- (a) Delete "libI77a"
-
- (b) Create a new empty project called "libI77a"
-
- (c) In the "Options" dialog select:
- - 4-byte integers
- - 8-byte doubles
- - 68020 code generation (strongly recommended, not required)
- - remove the prefix "#include <MacHeaders>"
- - add the prefix "#define NON_UNIX_STDIO" (for "libI77a" and "libI77b" only)
- - add the prefix "#define _POSIX_SOURCE" (for "libI77a" and "libI77b" only)
-
- (d) In the "Set Project Type" dialog select:
- - Far code
- - Far data
-
- (e) Open the text file "Contents of libI77a"
-
- (f) Add source files from the folder "libI77 Sources" as required to match
- the list that appears in "Contents of libI77a"
-
- (g) Bring the project up to date
-
- Repeat this process with "libI77b" and "libF77". "libF77" contains over
- one hundred files. You may find it easier to include all the source files
- in the folder "libF77 Sources" initially and then remove the handful that
- don't belong in "libF77".
-
-
-
- B. CONVERTING THE TEST PROJECT
- *******************************
-
- The folder "Test Project ƒ" contains a project file called "Test.π". In
- the folder "For THINK v6 and Earlier Users" is a text file called "Contents
- of Test.π". This file describes in detail the contents of the test
- project. To create a version compatible with your version of THINK C, do
- the following:
-
- (a) Delete "Test.π"
-
- (b) Create a new empty project called "Test.π"
-
- (c) In the "Options" dialog select:
- - 4-byte integers
- - 8-byte doubles
- - 68020 code generation (strongly recommended, not required)
- - remove the prefix "#include <MacHeaders>"
-
- (d) In the "Set Project Type" dialog select:
- - Far code
- - Far data
-
- (e) Open the text file "Contents of Test.π"
-
- (f) Add sources and libraries as required to match the list that appears
- in "Contents of Test.π" (You will not be able to add "Test.c"
- until you create it by translating "Test.f" with Mac F2C)
-
- (f) Segment the project as indicated in "Contents of Test.π" (in some
- versions of THINK C you cannot name the segments; this is not a
- problem, just ignore the segment names).
-
-
-
- C. HOW TO USE THE MODEL PROJECT
- ********************************
-
- The project model is the folder "Mac F2C Project" which is located in the
- folder "For '(Project Models)'". The folder "Mac F2C Project" contains
- the following files:
-
- (1) "@1.π" -- a THINK C version 7.0 project file.
-
- (2) "main.c" -- a driver program required to run programs compiled by
- Mac F2C.
-
- (3) "f2c.h" -- a header file required by code compiled by Mac F2C.
-
- This what you need to compile, link, and run files produced by Mac F2C.
- In THINK C version 7.0 or later, the THINK project manager automatically
- makes a copy of the entire model project (i.e., the entire "Mac F2C
- Project" folder) and renames the folder and project file when you create
- a new project using this model. To use the project model with versions
- of THINK C prior to 7.0, you will need to:
-
- (a) replace "@1.π" which a project compatible with your version of
- THINK C
-
- (b) every time you want to create a new project for Mac F2C code,
- duplicate the project model folder by hand and rename the folder
- and project file by hand.
-
- In the folder "For THINK v6 and Earlier Users" is a text file called
- "Contents of @1.π". This file describes in detail the contents of the
- model project. To create a version of "@1.π" compatible with your version
- of THINK C, do the following:
-
- (a) Delete "@1.π"
-
- (b) Create a new empty project called "@1.π"
-
- (c) In the "Options" dialog select:
- - 4-byte integers
- - 8-byte doubles
- - 68020 code generation (strongly recommended, not required)
- - remove the prefix "#include <MacHeaders>"
-
- (d) In the "Set Project Type" dialog select:
- - Far code
- - Far data
-
- (e) Open the text file "Contents of @1.π"
-
- (f) Add sources and libraries as required to match the list that appears
- in "Contents of @1.π"
-
- (g) Segment the project as indicated in "Contents of @1.π" (in some
- versions of THINK C you cannot name the segments; this is not a problem).
-
-
-
- D. IF YOU USE COMPILERS OTHER THAN THINK C
- *******************************************
-
- If you use a compiler other than THINK C, you will have to make libraries
- on your own and you will almost certainly have to make some minor
- modifications to some of the source files in the support libraries.
-
- You can use the "Contents of xxx" files in the "For THINK v6 and Earlier
- Users" folder to figure out what to put in each library. If your
- compiler/linker allows libraries larger than 32K, you can combine "libI77a"
- and "libI77b" into a single library. You could also combine all three
- ("libI77a", "libI77b", and "libF77") into a single library if you so
- desire.
-
- Make sure to compile the libraries so that integers are 4-bytes, doubles
- are 8-bytes, and you can have more than 32K of static/global data and jump
- tables larger than 32K. See the section on Using Code Produced by Mac F2C
- in the "INTRUCTIONS (THINK)" or "INSTRUCTIONS (CodeWarrior)" file for more
- information on these requirements and when they can be relaxed.
-
- You must also #define the following things when compiling these files:
-
- For "libF77"
-
- <None>
-
- For "libI77a" and "libI77b"
-
- #define NON_UNIX_STDIO -- force the use of ANSI standard I/O
- #define _POSIX_SOURCE -- force the use of mktemp() functions
-
- Most of the files in the Mac F2C support libraries compile without
- trouble on Macintoshes. Nevertheless, I had to modify a few files,
- and in doing so I sometimes had to rely on features specific to THINK
- C. The files in question are:
-
- In "libI77"
-
- access.c This function returns 0 if file called fileName
- exists, 1 otherwise. I wrote this from
- scratch using a Macintosh Toolbox call, so
- it should work with any Macintosh compiler.
-
- In "libF77"
-
- erf_fctns.c THINK C does not provide error functions in their
- library. I wrote my own. They have decent numeric
- properties and will compile with any ANSI C compiler.
- You may wish to replace it with (perhaps faster)
- vendor provided error functions.
-
- getenv_.c I had to write my own. I wrote one that returns a
- blank environment string. Modify as appropriate for
- your compiler.
-
- getpid.c I had to write my own. I exploited a global variable
- that is defined and maintained by the THINK C unix
- library. CodeWarrior doesn't define these, so we
- defined our own. You will have to modify this file
- to work with your system. If all else fails,
- return 0.
-
-
- Code produced by Mac F2C also relies on the THINK C ANSI and unix
- libraries. The THINK C ANSI library is exactly what it says it is. Your
- compiler should include such a library. The THINK C unix library provides
- a large collection of functions commonly available on unix systems. Your
- compiler may or may not include such a library. If it doesn't, you will
- get link errors when compiling programs produced by Mac F2C. You will have
- to provide the missing functions yourself. It's actually not hard to do,
- especially because in many cases you only need a place holder function
- (e.g., see "getenv_.c" or "getpid.c"). When a placeholder isn't enough,
- you can figure what the function needs to do by checking a unix manual or
- using the "man" command on a unix system.
-
- In any case make sure your versions of the ANSI and unix libraries are
- compiled with the proper options (4-byte integers, 8-byte doubles, jump
- tables larger than 32K, global data larger than 32K, and any C++
- compatibility options if you plan to ever produce C++ code as Mac F2C
- output).
-
- Finally, to run a program translated by Mac F2C, you need to link the
- following things together (this is automatically set up for THINK C users
- by the model project:
-
- - your translated code
- - "main.c"
- - libI77a
- - libI77b
- - libF77
- - ANSI
- - unix
-
- The file "main.c" is a driver that sets up a bunch of things and then calls
- the translated version of the FORTRAN main program. I modified "main.c" to
- use the THINK C console interface. In particular, "main.c" calls the
- function ccommand() to get command-line arguments from the user. You will
- need to modify this accordingly for your compiler.
-
- Good luck. If you have any questions, feel free to email me at
- igormt@alumni.caltech.edu. If you make a stable, general purpose port of
- the libraries and/or "main.c" to another Macintosh compiler, send me a copy
- and I will include it in future distributions of Mac F2C (with full credit
- and much gratitude).
-
-